package cn.com.pajx.pajx_visitor_v3.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.rcw.swiperefreshrecyclerview.BaseAdapter;
import com.rcw.swiperefreshrecyclerview.ViewHolder;

import java.util.List;

import cn.com.pajx.pajx_visitor_v3.R;
import cn.com.pajx.pajx_visitor_v3.bean.VisiteProgressBean;
import cn.com.pajx.pajx_visitor_v3.utils.DateUtil;

/**
 * Created by ruancw on 2024/8/16.
 * 预约拜访进度的Adapter
 */
public class VisiteProgressAdapter extends BaseAdapter<VisiteProgressBean> {

    public VisiteProgressAdapter(Context context, int layoutId, List<VisiteProgressBean> beans) {
        super(context, layoutId, beans);
    }

    @Override
    public void convert(ViewHolder holder, VisiteProgressBean bean, int position) {
        View viewLine = holder.getView(R.id.view_line);
        View viewLineUp = holder.getView(R.id.view_line_up);
        View viewLineDown = holder.getView(R.id.view_line_down);
        TextView tvCommonDes = holder.getView(R.id.tv_common_des);
        TextView tvCommonTime = holder.getView(R.id.tv_common_time);
        viewLine.setVisibility(position == 0 ? View.GONE : View.VISIBLE);
        viewLineUp.setVisibility(position == 0 ? View.INVISIBLE : View.VISIBLE);
        viewLineDown.setVisibility(datas.size() == 1 ? View.INVISIBLE : View.VISIBLE);
        viewLineDown.setVisibility(position == datas.size() - 1 ? View.INVISIBLE : View.VISIBLE);
        tvCommonDes.setText(bean.getTitle());
        tvCommonTime.setText(DateUtil.getAllTime(bean.getTime()));
    }

}
